
	const ESC	= "";
	const CSI = ESC + "[";
	const BEL = ESC + "[s";
	
	/* Foreground Colors */
	const BLK = ESC + "[30m"; /* Black */
	const RED = ESC + "[31m"; /* Red */
	const GRN = ESC + "[32m"; /* Green */
	const YEL = ESC + "[33m"; /* yellow */
	const BLU = ESC + "[34m"; /* Blue */
	const MAG = ESC + "[35m"; /* Magenta */
	const CYN = ESC + "[36m"; /* Cyan */
	const WHT = ESC + "[37m"; /* White */
	/* Hi Intensity Foreground Colors */
	const HIR = ESC + "[1;31m"; /* Red */
	const HIG = ESC + "[1;32m"; /* Green */
	const HIY = ESC + "[1;33m"; /* Yellow */
	const HIB = ESC + "[1;34m"; /* Blue */
	const HIM = ESC + "[1;35m"; /* Magenta */
	const HIC = ESC + "[1;36m"; /* Cyan */
	const HIW = ESC + "[1;37m"; /* White */
	/* High Intensity Background Colors */
	const HBRED = ESC + "[41;1m"; /* Red */
	const HBGRN = ESC + "[42;1m"; /* Green */
	const HBYEL = ESC + "[43;1m"; /* Yellow */
	const HBBLU = ESC + "[44;1m"; /* Blue */
	const HBMAG = ESC + "[45;1m"; /* Magenta */
	const HBCYN = ESC + "[46;1m"; /* Cyan */
	const HBWHT = ESC + "[47;1m"; /* White */
	/*  Background Colors  */
	const BBLK = ESC + "[40m";	  /* Black    */
	const BRED = ESC + "[41m";	  /* Red      */
	const BGRN = ESC + "[42m";	  /* Green    */
	const BYEL = ESC + "[43m";	  /* Yellow   */
	const BBLU = ESC + "[44m";	  /* Blue     */
	const BMAG = ESC + "[45m";	  /* Magenta  */
	const BCYN = ESC + "[46m";	  /* Cyan     */

	const NOR =  ESC + "[2;37;0m";      /* Puts everything back to normal */
	
	/**
	 * 特殊标签
	 */
	const NOR2 =  ESC + "[0;0m";     

//MUD协议特殊字符
	const ESA = "";
	
	//字串分隔符，比如向客户端发送场景中的多个npc信息，npc信息之间可用此分隔符连接
	const WZSEP = "$zj#";
	// const ZJSEP "$FF$"
	//菜单字串分隔符，一次向客户端发送多个菜单项，每项之间用此连接，菜单名字和关联命令之间用 '|' 连接
	const WZSP2 = "$z2#";
	//长描述换行符
	const WZBR = "$br#";
	// const WZURL(w) ESA + "[u:" + w + "]"
	// const WZSIZE(n) ESA + "[s:" + n + "]"
	const SYSY = ESA + "000";
	
	//场景名称标志，必须在行首，之后跟随的直到 '\n' 之前的内容将在客户端场景标题标签上显示，支持彩色显示
	//WZTITLE+ob->query("short")+"\n"....客户端收到WZTITLE标志设置标题的同时会清空出口和左侧场景物件栏
	const WZTITLE = ESA + "002";
	const WZEXIT = ESA + "003";
	//清除指定出口
	const WZEXITRM = ESA + "903";
	//清除所有出口
	const WZEXITCL = ESA + "913";
	const WZLONG = ESA + "004";
	  
	//场景左侧栏物件标志，必须在行首，之后跟随的直到 '\n' 之前的内容将在客户端场景左侧物件列表框中添加显示
	//WZOBIN+"name1:cmds1"WZSEP"name2:cmds2"......."\n"
	const WZOBIN = ESA + "005"; 
	    
	//客户端收到此消息。会将删除左侧栏对应物件。
	const WZOBOUT = ESA + "905";
	
	//推送自定义按钮定义，必须在行首，之后跟随的直到 '\n' 之前的内容将在客户端自定义按钮区处理，类似出口处理
	//WZBTSET+"b1:查看状态:score"WZSEP"b2:查看技能:skills"..."\n"
	//可以任意推送任何一个按钮不必每次全部推送，总共17个自定义按钮，分别b1-b17表示。(bxx:名称:命令)
	const WZBTSET = ESA + "006";
	
	//弹出描述标志，必须在行首，之后跟随的直到 '\n' 之前的内容将在客户端弹出框中显示，支持WZBR换行
	//此标志打头的文字信息会弹出显示，设计中可以配合文字点击协议灵活运用
	//WZOBLONG"这是一个巨大的石头(stone)，你可以试着"+WZURL("cmds:move stone")+"推动(move)"NOR"它。\n"
	const WZOBLONG = ESA + "007";
	
	//弹出窗口中的附加列表框，必须在行首，之后跟随的直到 '\n' 之前的内容将在客户端弹出框中的列表区中处理，作为可触摸命令按钮显示
	//次接口与文字点击接口功能类似，但是必须与WZOBLONG结合，可以根据需要灵活调用此接口或者文字点击接口。
	const WZOBACTS = ESA + "008";//按钮列表1，窄按钮，可根据需要灵活使用标志1或2
	const WZOBACTS2 = ESA + "009";//按钮列表2，自适应宽度按钮
	
	const WZYESNO = ESA + "010";
	 
	//必须在行首，之后跟随的直到 '\n' 之前的内容将在客户端地图框中显示，地图框支持WZBR换行
	const WZMAPTXT = ESA + "011";
	 
	//显示血条
	const WZHPTXT = ESA + "012";
	
	//配合start_more()使用，start_more()输出的内容将在客户端大文本阅读框中分页显示，支持WZBR换行
	const WZMORETXT = ESA + "013";
	 
	//既显既隐提示标志，必须在行首，之后跟随的直到 '\n' 之前的内容将在客户端临时消息框中渐显渐隐显示
	const WZTMPSAY = ESA + "015";
	//文字输入框
	//001当前频道【闲聊】，请输入内容：$zj#chat $txt#
	//或 001当前频道【闲聊】，请输入内容:$z2#我是下面的大段文字介绍$zj#chat $txt#
	//如果有WZWSP2 则表示有输入介绍
	const INPUTTXT = ESA + "001";
	
	//客户端弹出菜单标志，之后跟随的直到 '\n' 之前的内容将在客户端处理并弹出菜单
	//WZPOPMENU"菜单一|cmds1" WZSP2 "菜单二|cmds2"...."\n"
	
	//r列数，w列宽(屏宽/w)，h行高(屏宽/h)，s字号(屏宽/s)，
	const WZPOPMENU = ESA + "020";
	const WZRFBUT = ESA + "021";
	
	const WZFORCECMD = ESA + "014";
	
	//WZCHANNEL打头的行会在聊天频道框显示，此协议最好在/feature/message.c中的receive_message函数中添加
	const WZCHANNEL = ESA + "100";

	//客户端收到此消息会强行关闭客户端
	const SYSEXIT = ESA + "999";
	//网络错误
	const FNETERROR 	= ESA + "9999";
	const EC 			= "\\n"; // 结束符
	//场景生物属性
	const WZATTR 		= ESA + "051";
	const WZOPFGTBOX 	= ESA + "061";

	//登录成功
	const WZLGED 		= SYSY + "0007";
	//注册面板
    const WZREGBOX      = SYSY+"0008"


    //输入框中可以被替换的字符标记
    const  WZREPSTR = "$txt#";

	
	var ColorAry = new Array(
			 BLK,
			 RED,
			 GRN,
			 YEL,
			 BLU,
			 MAG,
			 CYN,
			 WHT,
			 HIR,
			 HIG ,
			 HIY ,
			 HIB,
			 HIM,
			 HIC,
			 HIW,
			 HBRED ,
			 HBGRN,
			 HBYEL,
			 HBBLU ,
			 HBMAG ,
			 HBCYN,
			 HBWHT,
			 BBLK,
			 BRED,
			 BGRN,
			 BYEL ,
			 BBLU,
			 BMAG,
			BCYN
	);

	String.prototype.startWith=function(s){
	  if(s==null||s==""||this.length==0||s.length>this.length)
	   return false;
	  if(this.substr(0,s.length)==s)
	     return true;
	  else
	     return false;
	  return true;
	 }




	//协议对象类型
	var ProtocolObjectType ={
		envObjectsStateAttr:"envObjectsStateAttr",
		channel:"channel",
		oncmds:"oncmds",
		roomDesc:"roomDesc",
		roomTitle:"roomTitle",
		window:"window",
		hpInfo:"hpInfo",
		roomObject:"roomObject",
		removeRoomObejct:"removeRoomObejct",
		removeExit:"removeExit",
        removeAllExit:"removeAllExit",
		openLongBox:"openLongBox",
		longBoxLB:"longBoxLB",
		longBoxRB:"longBoxRB",
		notification:"notification",
		butsGrop:"butsGrop",
		userButs:"userButs",
		fightFullScene:"fightFullScene",
		rightFiexButs:"rightFiexButs",
		map:"map",
		input:"input",
        exits:"exits",
		logined:"logined",
		sysExit:"sysExit",//强制关闭客户端
		regBox:"regBox",//注册面板
		
		
	};
    // var str =  "[u:cmds:enter dong][s:20][c:#ff0000][b:#ff0000]点我111[2;37;0m";

    //console.log( ansi_up.mudUrl(str))

    // var str  = "009$2,2,10,32#召唤物品:summon list$zj#[1;36m■[主][2;37;0m[1;36m盘古之心[2;37;0m*1$br#pgzx:i popmenu pgzx$zj#[1;31m暹罗宝盒-木[2;37;0m*1$br#xianluo2:i popmenu xianluo2$zj#[1;34m乌龟甲[2;37;0m*1$br#gui jia:i popmenu gui jia$zj#掌法总谱*1$br#shu:i popmenu shu$zj#[1;32m①新丁长衫[2;37;0m*1$br#new cloth:i popmenu new cloth$zj#[1;31m乾坤袋[2;37;0m*1$br#qiankun-box:apply qiankun-box$zj#";
    //var str = "100[1;36m【闲聊】[2;37;0m[1;36m[u:cmds:look ddjadmin][s:16]大当家[2;37;0m[1;36m：物品展示-[u:cmds:look gui jia of ddjadmin][s:14][1;34m乌龟甲[2;37;0m[2;37;0m";
    //
    // var str = "008$1,4,9,32#打听消息:ask xiao er about 消息";
    //   var str = "001当前频道【闲聊】，请输入内容:$zj#chat $txt#";
    //  var dataOBject = reosval.takeMessage(str);
    //   console.log(dataOBject);
    // //  console.log( ansi_up.ansi_to_html("[1;34masd",{useHex:true,useNoHtml:true} ));

	var Reosval = function(){};
    Reosval.prototype={
    	message:"",
	};
	Reosval.prototype = {
		 tmpVar:"",//临时变量
		 takeMessage:function(s){
			var t;
             t = s;

			// t = t.substring(0,10);
             /**
			  * 采花大屌扑在地上挣扎了几下，腿一伸，口中喷出几口[1;31m鲜血[2;37;0m，死了！
              [2;37;0m[1;32m通过这次锻炼，你获得了一百十六点经验、一百零五
              点潜能、能力得到了提升。
             [2;37;0m905look /fuben/caihua/npc/npc#429440
			  处理特殊标记
              */


             if (s.indexOf(NOR)==0) {
                 s = s.substr(NOR.length,s.length);

                 return this.takeMessage(s);
             }


				 //特殊符号会出现在第0个位置
				if (s.indexOf(WZATTR)==0){
					return this.analyseEvnObjectsStateAttr(s);
				 }else if(t.indexOf(WZCHANNEL)==0){//通道消息
					return this.analyseChannel(s);
			 	}else if(t.indexOf(WZFORCECMD)==0){//指令消息
			 		return this.analyseOncmds(s);
			 	}else if(t.indexOf(WZLONG)==0){//房间描述
			 		return this.analyseRoomDesc(s);
			 	}else if(t.indexOf(WZTITLE)==0){//房间标题
			 		return this.analyseRoomTitle(s);
			 	} else if(t.indexOf(WZEXIT)==0){//出口消息
			 		return this.analyseExits(s);
			 	} else if(t.indexOf(WZHPTXT)==0){//出口消息
			 		return this.analyseHpinfo(s);
			 	}else if(t.indexOf(WZOBIN)==0){//场景物件
			 		return this.analyseRoomObejct(s);
			 	}else if(t.indexOf(WZOBOUT)==0){//移除房间物件
			 		return this.analyseRemoveRoomObejct(s);
			 	}else if(t.indexOf(WZEXITRM)==0){//清除房间出口
					return this.analyseRemoveExit(s);
			 	}else if(t.indexOf(WZOBLONG)==0){//清除房间出口
					return this.analyseOpenLongBox(s);
			 	}else if(t.indexOf(WZOBACTS)==0){
			 		return this.analyseLongBoxLB(s);
			 	}else if(t.indexOf(WZOBACTS2)==0){
					return this.analyseLongBoxRB(s);
					
			 	}else if(t.indexOf(WZTMPSAY)==0){
					return this.analyseNotification(s);
			 	}else if(t.indexOf(WZBTSET)==0){
					return this.analyseButsGrop(s);
			 	}else if(t.indexOf(WZOPFGTBOX)==0){//全屏战斗
			 		
					return this.analyseFightFullScene(s);
			 	}else if(t.indexOf(WZRFBUT)==0){//首页右边浮动按钮
			 		return this.analyseRightFiexButs(s);
			 	}else if(t.indexOf(WZMAPTXT)==0){//地图
					return this.analyseMap(s);
			 	}else if(t.indexOf(INPUTTXT)==0){//文字输入框
					return this.analyseInput(s);
			 	}else if( t.indexOf(WZLGED)==0 ){
                    return this.analyseLogined(s);
				}else if(t.indexOf(WZEXITCL)==0){//隐藏所有出口 但不包括其他出口
                    return this.analyseRemoveAllExit(s);
				}else if(t.indexOf(SYSEXIT)==0){//强制退出
                    return this.analyseSysExit(s);
                }else if(t.indexOf(WZREGBOX)==0){//注册面板
                    return this.analyseRegBox(s);
                }else {//WINDOWD消息
			 		return  this.analyseWindow(s);
			 	} 


		 },

        analyseRegBox:function(s){
            s = s.replace(WZREGBOX,"");
            return {
                "type":ProtocolObjectType.regBox,
            }
        },

        analyseSysExit:function(s){
            s = s.replace(SYSEXIT,"");
            return {
                "type":ProtocolObjectType.sysExit,
            }
        },
        analyseRemoveAllExit:function(s){
            s = s.replace(WZEXITCL,"");
            return {
                "type":ProtocolObjectType.removeAllExit,
            }
        },
        analyseLogined:function(s){
		 	s = s.replace(WZLGED,"");
			return {
				"type":ProtocolObjectType.logined,
			}
		},
		//输入框
		 analyseInput:function(s){
		 	var ary=[],param=[],input={};
		 	s = s.replace(INPUTTXT,'');
		 	ary = s.split(WZSEP);
		 	input.hitText = "";
		 	input.desc ="";
		 	input.cmd="";

		 	//是否有介绍
			 if(ary[0].indexOf(WZSP2)>-1){
                 param = ary[0].split(WZSP2);
                 input.hitText = param[0];
                 input.desc = param[1];
                 input.cmd = ary[1];
			 }else{
                 input.hitText = ary[0];
                 input.cmd = ary[1];
			 }


		 	return {
		 		type:ProtocolObjectType.input,
		 		input:input
		 	};
		 },
		//地图
		 analyseMap:function(s){
		 	
		 	s = s.replace(WZMAPTXT,'');
		 	
		 	s = s.replace(/\$br#/g,'<br>');
		 	s = ansi_up.ansi_to_html(s,{useHex:true,useFontMode:true});
		 	return {
				"type": ProtocolObjectType.map,
				"text":s
			};
		 	return;
		 	
		 },
		 
		//分析周围生物属性
    ///051/d/xuedao/npc/yangzong#319341$zj#300:300
        analyseEvnObjectsStateAttr:function(s){
		 	var t,state={};
		 	s = s.replace(WZATTR,'');
			s = s.split(WZSEP);
			t = s[1].split(":");
            state.secId = s[0];
            state.min = t[0];
            state.max = t[1];
            return {
            	type:ProtocolObjectType.envObjectsStateAttr,
				state:state,
			}

		},

		//通道消息
		analyseChannel:function(s){
            s = s.replace(WZCHANNEL,'');
            s = ansi_up.mudUrl(s);
        	s = ansi_up.ansi_to_html(s,{useHex:true,useFontMode:true});


			return {
				"type": ProtocolObjectType.channel,
				"text":s
			};
		},

		//客户端相应消息
		analyseOncmds:function(s){
			return {
				"type": ProtocolObjectType.oncmds,
				"cmd":s.replace(WZFORCECMD,'')
			};
		},
		analyseRoomDesc:function(s){
		 	s = s.replace(WZLONG,'');
		 	s = ansi_up.ansi_to_html(s,{useHex:true,useFontMode:true});
			return {
				"type": ProtocolObjectType.roomDesc,
				"text":s,
			};
		},
		analyseRoomTitle:function(s){
            s = s.replace(WZTITLE,'');
            s = ansi_up.ansi_to_html(s,{useHex:true,useFontMode:true});
			return {
				"type": ProtocolObjectType.roomTitle,
				"text":s
			};
		},

		//增加出口的方向指示
        analyseExitTags:function(c,t){
		 	var e;
            if(c=="up"){
                e = "↑"+t;
            }else if(c=="down"){
                e = "↓"+t;
            }else if(c=="enter"){
                e = "●"+t;
            }else if(c=="out"){
                e = "○"+t;
            }else{
            	e = t;
			}
            return e;
		},

		 //多个出口的协议 003$zj#north:南河桥$zj#westup:山路
		analyseExits:function(s){
			
			var rt={},tary,exits=[];
			s = s.replace(WZEXIT,'');
			
			if(s.indexOf(WZSEP) > -1 ){


				s = s.split(WZSEP);


				//["east:东练功房", "west:后院", "south:南练功房"]
				for(var _t in s){
					if( s[_t]=="" ) continue;
					tary = s[_t].split(":");


                    tary[1] = this.analyseExitTags(tary[0],tary[1]);

					tary[1] = ansi_up.ansi_to_html(tary[1],{useHex:true,useFontMode:true});

                    exits.push({label:tary[1],cmd:tary[0]});

				}
			}else{
                tary = s.split(":");
                tary[1] = this.analyseExitTags(tary[0],tary[1]);

                tary[1] = ansi_up.ansi_to_html(tary[1],{useHex:true,useFontMode:true});
				exits.push({label:tary[1],cmd:tary[0]});
			}
			

			return {
				"type": ProtocolObjectType.exits,
				"exits":exits
			};
		},
		
		
		
		

		analyseWindow:function(s){
            s = ansi_up.mudUrl(s);
			return {
				"type": ProtocolObjectType.window,
				"text":ansi_up.ansi_to_html(s,{useHex:true,useFontMode:true}),
			};
		},
		analyseHpinfo:function(s){
			/*
			012经.2207557:2207557/1020:#BBFF00FF
			║气.1673:1673/1673/1673:#BBFF0000
			║内.3624:3624/3624/3755:#BB0000FF
			║精.3486:3486/3486/3486:#BBFF0066
			║潜.103900:103900/103900/103900:#BB006600
			║怒.0:0/0:#BB990000
			║元宝.17550:17550/17550:#DAA520
			║黄金.201027:201027/201027:#DAA520*/
			s = s.replace(WZHPTXT,'');
			
			var tAry,
				hp={},
				data=[],
				ary  =  s.split("║");
			
			for(var e in ary){
				hp={};
				tAry = ary[e].split(".");
				hp.txt = tAry[0];
				tAry   = tAry[1].split(":");
				
				if(tAry && tAry.length==3){
					hp.color = tAry[2];
				}
				tAry = tAry[1].split("/");
				if(tAry.length<=0){
					console.log("协议错误!");
					continue;
				}
				
				if(tAry.length==2){
					hp.min = tAry[0];
					hp.eff = tAry[1];
					hp.max = tAry[1];
				}else if(tAry.length==3){
					hp.min = tAry[0];
					hp.eff = tAry[1];
					hp.max = tAry[2];
				}
				
				data.push(hp);
			}
			
			//console.log(data);
			return {
				"type": ProtocolObjectType.hpInfo,
				"hp":data,
			};
		},
		analyseRoomObejct:function(s){
			var rt=[],tary;
			s = s.replace(WZOBIN,'');
			if( s.indexOf(WZSEP) > 0 ){
				s = s.split(WZSEP);
				for(var e in s){
					tary = s[e].split(":");
                    tary[0] = ansi_up.ansi_to_html(tary[0],{useHex:true,useFontMode:true})
					rt.push({"objectTitle":tary[0],"objectFile":tary[1]});
				}
			}else{
				//console.log(s);
				tary = s.split(":");
                tary[0] = ansi_up.ansi_to_html(tary[0],{useHex:true,useFontMode:true})
				rt.push({"objectTitle":tary[0],"objectFile":tary[1]});
			}
			return {
				"type": ProtocolObjectType.roomObject,
				"objects":rt
			};
		},
		analyseRemoveRoomObejct:function(s){
			
			var text =  s.replace(WZOBOUT,'');
			return{
				"type":ProtocolObjectType.removeRoomObejct,
				"text":text
			};
		},
		//删除指定出口
		analyseRemoveExit:function(s){
			
			var exit =  s.replace(WZEXITRM,'');
			return{
				"type":ProtocolObjectType.removeExit,
				"exit":exit
			};
		},
		analyseOpenLongBox:function(s){
		 	s = s.replace(WZOBLONG,'');
			s = s.split("\n");
			var t = s[0];
			t = t.replace(/\$br#/g,'<br>');
            t = ansi_up.mudUrl(t);
            t = ansi_up.ansi_to_html(t,{useHex:true,useFontMode:true});

			return{
				"type":ProtocolObjectType.openLongBox,
				"text":t,
				
			};
		},
		analyseLongBoxLB:function(s){
			
			var param,p,args;
			var buts=[];
			var butStyle={};
			



            s =  s.replace(/00\d\$(\d+?),(\d+?),(\d+?),(\d+?)#(.*)+?/g,function(){

                butStyle.rowNumber = arguments[1];
                butStyle.colNumber = arguments[2];
                butStyle.width     = arguments[3];
                butStyle.height    = arguments[4];

                return arguments[5];

            });



			
			if(s.indexOf(WZSEP)>=0){


                s = s.split(WZSEP);
				for(p in s){

					param = s[p].split(":");
					param[0] = param[0].replace(/\$br#/g,'<br>');
                    param[0] = ansi_up.ansi_to_html(param[0],{useHex:true,useFontMode:true});
					buts.push({"label":param[0],"cmd":param[1]});
				}
				
			}else{

                param = s.split(":");

                param[0] = param[0].replace(/\$br#/g,'<br>');
                param[0] = ansi_up.ansi_to_html(param[0],{useHex:true,useFontMode:true});
                buts.push({"label":param[0],"cmd":param[1]});
				
			}
			

			return{
				"type":ProtocolObjectType.longBoxLB,
				"leftButList":buts,
				"butStyle":butStyle,
				
			};
		},

		//var str  = "009$2,2,10,32#召唤物品:summon list$zj#[1;36m■[主][2;37;0m[1;36m盘古之心[2;37;0m*1$br#pgzx:i popmenu pgzx$zj#[1;31m暹罗宝盒-木[2;37;0m*1$br#xianluo2:i popmenu xianluo2$zj#[1;34m乌龟甲[2;37;0m*1$br#gui jia:i popmenu gui jia$zj#掌法总谱*1$br#shu:i popmenu shu$zj#[1;32m①新丁长衫[2;37;0m*1$br#new cloth:i popmenu new cloth$zj#[1;31m乾坤袋[2;37;0m*1$br#qiankun-box:apply qiankun-box$zj#";
		analyseLongBoxRB:function(s){
			
			var param,p,args; //s.match(/\$(.*)+?$#/);
			var buts=[];
			//必须有默认数据
			var butStyle={
				rowNumber:2,
                colNumber:2,
                width:9,
                height:40,
			};
			

			s =  s.replace(/00\d\$(\d+?),(\d+?),(\d+?),(\d+?)#(.*)+?/g,function(){

                butStyle.rowNumber = arguments[1];
                butStyle.colNumber = arguments[2];
                butStyle.width     = arguments[3];
                butStyle.height    = arguments[4];
                return arguments[5];

			});

            s = s.replace(WZOBACTS2,"");

			if(s.indexOf(WZSEP)>-1){

				s = s.split(WZSEP);
				for(p in s){
					//容错

					if(s[p].indexOf(":") < 0) continue;
                    param = s[p];
					param = param.split(":");
					param[0] = param[0].replace(/\$br#/g,'<br>');
					param[0] = param[0].replace(/\$br/g,'<br>');
					param[0] = ansi_up.ansi_to_html(param[0],{useHex:true,useFontMode:true});
					buts.push({"label":param[0],"cmd":param[1]});
				}

			}else{

                if(s.indexOf(":") < 0) return;
                param = s;
                param = param.split(":");
                param[0] = param[0].replace(/\$br#/g,'<br>');
                param[0] = param[0].replace(/\$br/g,'<br>');
                param[0] = ansi_up.ansi_to_html(param[0],{useHex:true,useFontMode:true});
                buts.push({"label":param[0],"cmd":param[1]});
				
			}

		
			
			return{
				"type":ProtocolObjectType.longBoxRB,
				"rightButList":buts,
				"butStyle":butStyle,
			};
		},

		analyseNotification:function(s){
			s = s.replace(WZTMPSAY,'');
			return{
				"type":ProtocolObjectType.notification,
				"text":s,
			};
		},
		
		/**
		 * 用户按钮组
		 *
		 * 	006b20:指令$br#输入:appinput$zj#b12:角色$br#信息:mycmds ofen$zj#b12:背包$br#物品:i$zj#b13:技能$br#相关:mycmds skill$zj#b14:战斗$br#相关:mycmds fight$zj#b15:任务$br#相关:mycmds quest$zj#b16:频道$br#交流:liaotian
		 *
		 */
		analyseButsGrop:function(s){
			
			var e,
				ary,tary,
				buts=[],
				footerButs=[],//底部按钮
				userButs=[];//自定义按钮区
			s = s.replace(WZBTSET,'');
			s = s.split(WZSEP);
			for(e in s ){
				e = s[e];
				ary = e.split(":");
				if(ary.length < 3 ) continue;
                //判断按钮的区别
                tary = ary[0].toLowerCase().split("b");
                if(tary.length < 2) continue;
                tary = parseInt(tary[1]);
				if( tary < 31 ){
					//都是用户按钮区的按钮
                    ary[1] = ary[1].replace(/\$br#/g,'<br>');
                    userButs.push({"label":ary[1],"cmd":ary[2]});
				}else{
                    ary[1] = ary[1].replace(/\$br#/g,'\n');

                    footerButs.push({"label":ary[1],"cmd":ary[2]});
				}

			}
			
			return{
				"type":ProtocolObjectType.butsGrop,
				"buts":{footerButs:footerButs,userButs:userButs},
			};
			
		},
		//全屏战斗
		analyseFightFullScene:function(s){
			
			var e,ary,buts=[];
			s = s.replace(WZOPFGTBOX,'');
			s = s.split(WZSEP);
			
			for(e in s){
				ary = s[e].split("WZSP2");
			}
			
			
			
			return{
				"type":ProtocolObjectType.butsGrop,
				"buts":buts,
			};
			
		},
		analyseRightFiexButs:function(s){
			var e,ary,buts=[];
			s = s.replace(WZRFBUT,'');
			s = s.split(WZSEP);
			
			for(e in s){
				if(s[e].indexOf(":") < 0) continue;
				ary = s[e].split(":");
				buts.push({label:ary[0],cmd:ary[1]});
			}
			return{
				"type":ProtocolObjectType.rightFiexButs,
				"buts":buts,
			};
			
			
		},
		
	};


    var reosval = new Reosval();

    function takeMessage(data){
        ///xxx
        //console.log("【JS android data】");
       // console.log(data);
        var dataOBject = reosval.takeMessage(data);
        window.App.onTakeMessage(JSON.stringify(dataOBject));
    }


